//
//  LabelOfButton.m
//  UI_homework_03_封装UIButton
//
//  Created by li cheng on 16/7/18.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "LabelOfButton.h"
@class UITapGestureRecognizer;
@implementation LabelOfButton

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
//        self.userInteractionEnabled = YES;
    }
    return self;
}


//- (void)addClickEvent:(SEL)sel addTarget:(UIView *)target{
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sel)];
//    // 点击几次触发方法,默认为1
//    tap.numberOfTapsRequired = 1;
//    // 几个手指触发 (按option - alt),默认为1
//    tap.numberOfTouchesRequired = 1;
//    [target addGestureRecognizer:tap];
//    
//}
//- (void)addWithTarget:(id)target action:(SEL)action {
//    UILongPressGestureRecognizer *tap = [[UILongPressGestureRecognizer alloc] initWithTarget:target action:@selector(action)];
//    tap.minimumPressDuration = 0;
////    [self.nextResponder addGestureRecognizer:tap];
////    return self;
//}
//
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    [super touchesBegan:touches withEvent:event];
////    @selector(<#selector#>)
//    
//    NSLog(@"我是按钮");
//}

//+ (void)


- (nonnull instancetype)initWithFrame:(CGRect)frame text:(nullable NSString *)text target:(nullable id)target action:(nullable SEL)action backColor:(nullable UIColor *)backColor textColor:(nullable UIColor *)textColor{
    self = [super initWithFrame:frame];
    if (self) {
        self.text = text;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:target action:action];
        [self addGestureRecognizer:tap];
        self.backgroundColor = backColor;
        self.textColor = textColor;
        self.userInteractionEnabled = YES;
        self.textAlignment = NSTextAlignmentCenter;
    }
    return self;
}

@end
